from django.forms.models import model_to_dict

class serialize():
    @staticmethod
    def to_dict(instance):
        field = ["CreatedAt","UpdatedAt"]
        data = model_to_dict(instance)
        for f in field:
            if hasattr(instance,f):
                data[f] = instance.__dict__[f]
        return data